package com.saihai.jiankang.ufXngl.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.saihai.common.annotation.Log;
import com.saihai.common.core.controller.BaseController;
import com.saihai.common.core.domain.AjaxResult;
import com.saihai.common.enums.BusinessType;
import com.saihai.jiankang.ufXngl.domain.UfXngl;
import com.saihai.jiankang.ufXngl.service.IUfXnglService;
import com.saihai.common.utils.poi.ExcelUtil;
import com.saihai.common.core.page.TableDataInfo;

/**
 * 学年管理Controller
 * 
 * @author ruoyi
 * @date 2024-07-29
 */
@RestController
@RequestMapping("/jiankang/ufXngl")
public class UfXnglController extends BaseController
{
    @Autowired
    private IUfXnglService ufXnglService;

    /**
     * 查询学年管理列表
     */
    @GetMapping("/list")
    public TableDataInfo list(UfXngl ufXngl)
    {
        List<UfXngl> list = ufXnglService.selectUfXnglList(ufXngl);
        return getDataTable(list);
    }

    /**
     * 导出学年管理列表
     */
    @PreAuthorize("@ss.hasPermi('jiankang:ufXngl:export')")
    @Log(title = "学年管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, UfXngl ufXngl)
    {
        List<UfXngl> list = ufXnglService.selectUfXnglList(ufXngl);
        ExcelUtil<UfXngl> util = new ExcelUtil<UfXngl>(UfXngl.class);
        util.exportExcel(response, list, "学年管理数据");
    }

    /**
     * 获取学年管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('jiankang:ufXngl:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(ufXnglService.selectUfXnglById(id));
    }

    /**
     * 新增学年管理
     */
    @PreAuthorize("@ss.hasPermi('jiankang:ufXngl:add')")
    @Log(title = "学年管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody UfXngl ufXngl)
    {
        return toAjax(ufXnglService.insertUfXngl(ufXngl));
    }

    /**
     * 修改学年管理
     */
    @PreAuthorize("@ss.hasPermi('jiankang:ufXngl:edit')")
    @Log(title = "学年管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody UfXngl ufXngl)
    {
        return toAjax(ufXnglService.updateUfXngl(ufXngl));
    }

    /**
     * 删除学年管理
     */
    @PreAuthorize("@ss.hasPermi('jiankang:ufXngl:remove')")
    @Log(title = "学年管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(ufXnglService.deleteUfXnglByIds(ids));
    }
}
